import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EnterpriseInfoVO, EnterpriseInfoForm, EnterpriseInfoQuery } from '@/api/platform/enterpriseInfo/types';

/**
 * 查询企业信息列表
 * @param query
 * @returns {*}
 */

export const listEnterpriseInfo = (query?: EnterpriseInfoQuery): AxiosPromise<EnterpriseInfoVO[]> => {
  return request({
    url: '/platform/enterpriseInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询企业信息详细
 * @param id
 */
export const getEnterpriseInfo = (id: string | number): AxiosPromise<EnterpriseInfoVO> => {
  return request({
    url: '/platform/enterpriseInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增企业信息
 * @param data
 */
export const addEnterpriseInfo = (data: EnterpriseInfoForm) => {
  return request({
    url: '/platform/enterpriseInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改企业信息
 * @param data
 */
export const updateEnterpriseInfo = (data: EnterpriseInfoForm) => {
  return request({
    url: '/platform/enterpriseInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除企业信息
 * @param id
 */
export const delEnterpriseInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/platform/enterpriseInfo/' + id,
    method: 'delete'
  });
};

/**
 * 注册小程序
 * @param data
 */
export const registerMiniprogram = (data: EnterpriseInfoForm) => {
  return request({
    url: '/platform/enterpriseInfo/registerMiniprogram',
    method: 'post',
    data: data
  });
};

/**
 * 授权
 * @param data
 */
export const goto_auth_url = () => {
  return request({
    url: '/wechat/api/auth/goto_auth_url',
    method: 'get'
  });
};